<template>
    <view class="content">
        <view class="top">
			<view class="title">{{centerData.name}}</view>
			<view class="add">
				<view class="u-flex-1">
					<view class="distance" v-if="centerData.distance">距您 {{centerData.distance}}</view>
					<view>{{centerData.address}}</view>
				</view>
				<image src="../../static/image/add.png" class="add-icon"></image>
			</view>
		</view>
		
		<view class="item" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
			<view class="item-top">
				<view class="name">{{item.name}}</view>
				<view class="more">
					查看详情
					<u-icon name="arrow-right" color="#919191" size="28" class="u-m-l-10"></u-icon>
				</view>
			</view>
			<view class="item-down" v-if="item.child && item.child.length > 0">
				<view class="text" v-for="(el, ind) in item.child" :key="ind">{{el.name}}</view>
			</view>
		</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
				list: [],
                id: '',
				centerData: {},
				// name: '',
				// address: '',
				// distance: '',
            };
        },
        onLoad(option) {
			if (option.id) { this.id = option.id }
			// if (option.name) { this.name = option.name }
			// if (option.address) { this.address = option.address }
			// if (option.distance) { this.distance = option.distance }
            this.getList()
			
			this.$getLocation((latitude,longitude) => {
			    console.log('000',latitude, longitude)
			    let lat = latitude
				let log = longitude
				
				this.getCentersData(lat,log)
			})
        },
        methods: {
			toDetails(item) {
				// this.$gTo(`./details?id=${this.id}&name=${this.name}&address=${this.address}&distance=${this.distance}&thalis_id=${item.id}`)
				this.$gTo(`./details?id=${this.id}&thalis_id=${item.id}`)
			},
			
            getList() {
            	this.$ajax('get_thalis', {
                    userToken: this.$getSync('userToken'),
					center_id: this.id,//体检中心编号
                }).then(ret => {
            		if (ret.status == 0) {
                        this.list = ret.data
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
			
			// 获取体检中心详情
			getCentersData(lat,lng) {
				this.$ajax('get_centers_detail', {
			        userToken: this.$getSync('userToken'),
					centers_id: this.id,//体检中心编号
					lat: lat,
					lng: lng,
			    }).then(ret => {
					if (ret.status == 0) {
			            this.centerData = ret.data
					} else {
						this.$toast(ret.message);
					}
				});
			},
        }
    };
</script>

<style lang="scss">
	
	
	
	
    page{
        background-color: #f5f5f5;
    }
	.content{
		padding: 20rpx;
	}
	.top{
		background-color: #01b6bc;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
	}
	.title{
		font-size: 36rpx;
		color: #fff;
		padding: 36rpx;
	}
	.add{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 40rpx 35rpx;
		background-color: #fff;
		border-radius: 20rpx;
		font-size: 26rpx;
	}
	.distance{
		font-size: 28rpx;
		color: #01b6bc;
	}
	.add-icon{
		width: 67rpx;
		height: 67rpx;
		margin-left: 15rpx;
	}
	.item{
		padding: 32rpx;
		margin-bottom: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}
	.item-top{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.name{
		flex: 1;
		font-size: 30rpx;
		font-weight: bold;
		position: relative;
	}
	.name::after{
		display: block;
		content: '';
		width: 8rpx;
		height: 37rpx;
		background-color: #01b6bc;
		border-radius: 0 6rpx 6rpx 0;
		position: absolute;
		left: -30rpx;
		top: 0;
	}
	.more{
		font-size: 24rpx;
		color: #9f9fa0;
	}
	.item-down{
		padding-top: 10rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		align-items: center;
	}
	.text{
		font-size: 26rpx;
		padding: 10rpx 12rpx;
		background-color: #f1f1f1;
		border-radius: 4rpx;
		margin-right: 10rpx;
		margin-top: 10rpx;
	}
	
	

</style>
